<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header {
        height: 100px;
        background-color: #aef;
      }
  
      main {
        height: 350px;
        background-color: #ceb;
      }
  
      footer {
        height: 100px;
        background-color: #fea;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明一个类 注意: 名字一定要大写
      class Header extends React.Component{
        // 声明一个方法叫 render (名字不能修改)
        render(){
          return <header>xxx</header>;
        }
      }
      
      function render(vnode, parent){
        //实例化对象
        let instance = new vnode.type();
        //调用 render 方法
        let vdom = instance.render();
        //创建真是 DOM 节点
        let el = document.createElement(vdom.type);
        //插入
        parent.append(el);
      }

      render(<Header />, document.querySelector('#root'));
    </script>
  </body>
</html>
